<?php

class Config_Xml_Factory {
	const CONFIG_DIR = '/config/'; 
	
	public static function factory($configName, $cache = false) {
		$path = BASE_DIR . self::CONFIG_DIR . $configName . '.xml';
		$localPath = BASE_DIR . self::CONFIG_DIR  . $configName . '.local.xml';
		
		if (!is_readable($path)) {
			throw new Exception("Cannot read $path file");
		}

		if ($cache) {
			$config = new Config_Xml_Cache($path, null, true);
		} else {
			$config = new Zend_Config_Xml($path, null, true);
		}
		
		$config->setReadOnly();
		return $config;
	}
}